package com.san.app.task;

import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.san.app.service.InspectResultService;
import com.san.app.service.InspectService;
import com.san.app.vo.InspectResultVO;

/**
 * 信用核查线程
 * @author SuperSR
 * @date 2019年4月3日 上午11:54:22
 *
 */
public class InspectThread extends Thread{

	private static final Logger logger = LoggerFactory.getLogger(InspectThread.class);
	
	private InspectService inspectService;
	private List<List<String>> datas;
	private Long inspectId;
	private HttpServletResponse response;
	private Long userId;
	
	
	public InspectThread(InspectService inspectService,List<List<String>> datas,Long inspectId,HttpServletResponse response,Long userId){
		this.inspectService = inspectService;
		this.datas = datas;
		this.inspectId = inspectId;
		this.response = response;
		this.userId = userId;
	}
	
	@Override
	public void run() {
		Date date = new Date();
		Long batchNo = date.getTime();
		
		//批量导入方法
		//inspectManager.getCheckResult(templateSql, obj, dataSourceDO);
		List<Object> list =  inspectService.doCheck(datas, inspectId,batchNo);
		System.out.println(list);
		//生成Excel文件方法,并将生成文件信息存入数据库中,向操作用户发送通通知
		inspectService.exportExcel(inspectId,list, date, batchNo,response,userId);
		
	}

	/**
	 * 随机生成一个批次号
	 * @return
	 */
	/*private String getSerialNumber() {
		int length=10;
        String base = "abcdefghijklmnopqrstuvwxyz0123456789";  
        Random random = new Random();  
        StringBuffer sb = new StringBuffer();  
        for (int i = 0; i < length; i++) {  
            int number = random.nextInt(base.length());  
            sb.append(base.charAt(number));  
        }
        return sb.toString();
	}*/
	
}
